<form class="layui-form open-form" lay-filter="skuTableForm" id="skuTableForm">
  <div class="open-model">
    <div class="open-auto">
      <table id="processInfoDetailTable" lay-filter="processInfoDetailTable"></table>
      <!-- 添加按钮 -->
      <button class="layui-btn" id="addProcessExceptionBtn" type="button">添加</button>
      <table id="processInfoTableList" lay-filter="processInfoTableList"></table>
    </div>
  </div>
</form>

<script>
  layui.use(["layer", "form", "table", "admin", "upload", "tree", "laytpl"], async function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var config = layui.config;
    var admin = layui.admin;
    const nowData = { ...parentData };
    const data = { ...nowData.data };

    table.render({
      elem: "#processInfoDetailTable",
      cellMinWidth: 100,
      data: [data],
      cols: [
        [
          { field: "nodeNames", align: "center", title: "工序节点名称" },
          { field: "nodeCodes", align: "center", title: "工序节点编号" },
          { field: "remark", align: "center", title: "备注说明" },
          {
            field: "qualityIf",
            align: "center",
            title: "是否支持委外",
            templet: function (d) {
              return d.isOutsource === "0" ? "是" : "否";
            }
          },

          { field: "nodeTypesName", align: "center", title: "工序类型" },
          { field: "processNatureName", align: "center", title: "工序性质" },
          // { field: "mainUnitName", align: "center", title: "抽检" },
          {
            field: "processWarehouseIf",
            align: "center",
            title: "创建工序仓",
            templet: function (d) {
              return d.processWarehouseIf === "0" ? "是" : "否";
            }
          },
          { field: "createUserName", align: "center", title: "创建人" },
          { field: "createTime", align: "center", title: "创建时间" }
        ]
      ]
    });
    table.render({
      elem: "#processInfoTableList",
      url: config.base + "enterprise/product/admin/processInfo/abnormalCauseList",
      where: {
        processId: data.id
      },
      cellMinWidth: 100,
      cols: [
        [
          //   { type: "numbers", title: "序号" },
          { field: "code", align: "center", title: "异常原因代码" },
          { field: "name", align: "center", title: "异常原因名称" },
          { field: "processName", align: "center", title: "所属工序" },
          {
            field: "remark",
            align: "center",
            title: "备注说明"
          },

          { field: "statusName", align: "center", title: "状态" },
          { field: "creatorName", align: "center", title: "操作人" },
          { field: "createTime", align: "center", title: "创建时间" },
          {
            field: "action",
            align: "center",
            title: "操作",
            templet: function (d) {
              return `<button class="layui-btn type='button' layui-btn-xs" lay-event="edit">编辑</button>`;
            }
          }
        ]
      ]
    });
    $("#addProcessExceptionBtn").on("click", function () {
      admin.formOpen({
        offset: "15%",
        title: "添加异常原因",
        path: "components/product/processExceptionByprocessExceptionForm.html",
        success: function () {
          parentData.data = data;
          parentData.eventName = "edit";
            
        }
      });
    });
    table.on("tool(processInfoTableList)", function (obj) {
      var data = obj.data;
      console.log(obj);

      if (obj.event === "edit") {
        admin.formOpen({
          offset: "15%",
          title: "编辑异常原因",
          path: "components/product/processExceptionByprocessExceptionForm.html",
          success: function () {
            parentData.data = data;
            parentData.eventName = "edit";
          }
        });
      }
    });
  });
</script>
<style>
  #skuTableForm .layui-input-block {
    margin-left: 130px;
  }
</style>
